<style>
    header.panel-heading a{display: block;background-color: #46b8da;padding: 3px 8px;color: #fff;border-radius: 3px;}
    
    #formorder a:hover{background-color: #46b8da;}
	#formorder .onmous span{color: #fff;display: none;font-size: 12px;}
    
    #add{border-top: 1px solid #E0E0E0;text-align: center;}
    #add a{display: inline-block;padding: 10px 0;}
    
    #formorder{overflow: auto;}
    #formorder table{width: 100%;}
    #formorder table thead tr th,#formorder table tbody tr td{border: 1px solid #d3d2d2;text-align: center;width: 250px;}
    #formorder table thead tr th{padding: 5px;color: #666666;font-weight: 500;background: #f0f0f0;cursor: default;height: 50px;}
    #formorder table tbody tr td{cursor: default;padding: 5px;min-width: 100px;height: 50px;}
    #formorder .tables_thall tr{display: none;}
    #formorder .tables_thall tr.types_top{display: table-row;background-color: #DDDDDD;}
    #formorder .tables_thall tr.types_top td{cursor: pointer;}
    #formorder .tables_thall tr.types_zi td:hover{background-color: #FFF0F0;}
    #formorder table.active tr{display: table-row;}
    #formorder table select{width: 60px;border: 1px solid #d3d2d2;padding: 3px 5px;color: #717171;}
    #formorder table input.yes{width: 100px;border: 1px solid #d3d2d2;padding: 3px 5px;color: #717171;}
    #formorder table tr td.for_post input{width: 80px;margin: 5px;}
    #formorder table input[name="set_thprice"]{background-color: #fff;border: 1px solid transparent;max-width: 40px;color: #FF7575;font-weight: bold;text-align: right;cursor: pointer;}
    #formorder .tables_thall tr.types_zi td:hover input[name="set_thprice"]{background-color: #FFF0F0;}
    
    
    #pop-up-boxes{
        position: fixed;width: 100%;height: 100%;z-index: 20;top: 0;left: 0;display: none;
    }
    #pop-up-boxes-content{
        width: 500px;margin: 0 auto;font-size: 14px;
        border: 1px solid black;color: black;
        margin-top: 10%;background-color: #fff;border-radius: 10px;
    }
    #pop-up-boxes-title img{
        cursor: pointer;float: right;left: 0;top: 17px;width: 16px;height: 16px;margin: 3px;border: none;border-radius: 10px;
    }
    #pop-up-boxes-text{padding: 20px;text-align: center;color: #555555;}
	#pop-up-boxes-text div{max-height: 300px;overflow:auto;}
	#pop-up-boxes-text div::-webkit-scrollbar{width: 2px;}
    #pop-up-boxes-text input,#pop-up-boxes-text select{width: 100px;padding: 3px;}
    #pop-up-boxes-text button{padding: 3px 10px;border: 1px solid #46b8da;background-color: #46b8da;color: #fff;border-radius: 3px;}
	#pop-up-boxes-text table{width: 100%;}
    #pop-up-boxes-text table thead tr th,#pop-up-boxes-text table tbody tr td{border: 1px solid #d3d2d2;text-align: center;width: 25%;}
    #pop-up-boxes-text table thead tr th{color: #666666;font-weight: 500;background: #f0f0f0;cursor: default;height: 35px;}
    #pop-up-boxes-text table tbody tr td{cursor: default;height: 35px;}
	
    .ui-datepicker-trigger{display: none;}
</style>
<link rel="stylesheet" href="/public/assets/sysadmin/mylzp/css/jquery-ui.css">
<script type="text/javascript" src="/public/assets/sysadmin/mylzp/js/jquery-ui.js"></script>
<section class="vbox">
    <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
            <li><a href="#"><i class="fa fa-home"></i>酒店管理中心</a></li>
            <li><a href="#">酒店管理</a></li>
            <li><a href="#">价格政策</a></li>
        </ul>
        <div class="m-b-md">
            <h3 class="m-b-none"><span style="float:right;"></span>价格政策</h3>
        </div>
        <section class="panel panel-default">
            <header class="panel-heading">
                <i data-title="ajax to load the data." data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""></i>
                <b>价格政策</b>
                <label style="font-size: 12px;font-weight: normal;color: #FF6F6F;"></label>
                <a href="<?=$this->url("hotel/priceupdate")?>" style="float:right;">价格浮动设置</a>
            </header>
            <div id="formorder">
                <table>
                    <thead>
                        <tr>
                            <th>类型</th>
                            <th>当前折扣(早餐数)</th>
                            <th>折扣价(房价记录)</th>
                            <th>开始时间</th>
                            <th>结束时间</th>
                            <th>类型选择</th>
                            <th>渠道选择</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                </table>
                <?
                if($types){
                    foreach($types as $k=>$v){?>
                    <form action="<?=$this->url('hotel/priceEdit')?>" method="post" class="form-horizontal form-bordered form-validate" id="from_th_<?=$k?>">
                    <table class="types_table_<?=$k?> <?=$k==0?'active':''?> tables_thall">
                        <tbody>
                            <tr class="types_top" lang="<?=$k?>">
                                <td colspan="8"><b><?=$v['title']?></b>&nbsp;&nbsp;&nbsp;底价：<label style="color: #FF7575;font-size: 20px;cursor: pointer;"><?=$v['price']?></label> ￥ &nbsp;&nbsp;&nbsp;<span lang="<?=$k==0?0:1?>" style="font-size: 12px;"><?=$k==0?'收起∧':'展开∨'?></span></td>
                            </tr>
                            <?
                            if($parentTypes){
                                foreach($parentTypes as $key=>$val){
                                    if($v['id']==$val['parentTypeId']){?>
                                        <tr class="types_zi">
                                            <td>
                                                <?
                                                if($val['zisort']==1){?>
                                                    含早
                                                <?}elseif($val['zisort']==2){?>
                                                    不含早
                                                <?}elseif($val['zisort']==3){?>
                                                    提前 <select name="thDay[<?=$val['id']?>]"><?for($i=1;$i<61;$i++){?><option value="<?=$i?>" <?=!empty($val['thDay'])&&$val['thDay']==$i?'selected':''?> ><?=$i?></option><?}?></select> 天以上预订
                                                <?}elseif($val['zisort']==4){?>
                                                    连续 <select name="thDay[<?=$val['id']?>]"><?for($i=1;$i<61;$i++){?><option value="<?=$i?>" <?=!empty($val['thDay'])&&$val['thDay']==$i?'selected':''?> ><?=$i?></option><?}?></select> 天以上入住
                                                <?}elseif($val['zisort']==5){?>
                                                    含早(现付)
                                                <?}elseif($val['zisort']==6){?>
                                                    不含早(现付)
                                                <?}elseif($val['zisort']==7){?>
                                                    提前 <select name="thDay[<?=$val['id']?>]"><?for($i=1;$i<61;$i++){?><option value="<?=$i?>" <?=!empty($val['thDay'])&&$val['thDay']==$i?'selected':''?> ><?=$i?></option><?}?></select> 天以上预订(现付)
                                                <?}elseif($val['zisort']==8){?>
                                                    连续 <select name="thDay[<?=$val['id']?>]"><?for($i=1;$i<61;$i++){?><option value="<?=$i?>" <?=!empty($val['thDay'])&&$val['thDay']==$i?'selected':''?> ><?=$i?></option><?}?></select> 天以上入住(现付)
                                                <?}
                                                ?>
                                            </td>
                                            <td>
                                                <select name="rebate[<?=$val['id']?>]" class="setPrice" lang="<?=$v['price']?>">
                                                    <?
                                                    if($pmsconfigs){
                                                        foreach($pmsconfigs['zhekou'] as $kv=>$av){?>
                                                            <option value="<?=$kv?>" <?=!empty($val['rebate'])&&$val['rebate']==$kv?'selected':''?> ><?=$av?></option>
                                                        <?}
                                                    }
                                                    ?>
                                                </select> 折
												<?
												if($val['zisort']==1||$val['zisort']==5){?>
													<select name="breakfast[<?=$val['id']?>]" style="width: 45px;">
														<option value="1" <?=($val['breakfast']==0||$val['breakfast']==1)?'selected':''?> >1</option>
														<option value="2" <?=$val['breakfast']==2?'selected':''?> >2</option>
														<option value="3" <?=$val['breakfast']==3?'selected':''?> >3</option>
														<option value="4" <?=$val['breakfast']==4?'selected':''?> >4</option>
														<option value="5" <?=$val['breakfast']==5?'selected':''?> >5</option>
														<option value="6" <?=$val['breakfast']==6?'selected':''?> >6</option>
														<option value="7" <?=$val['breakfast']==7?'selected':''?> >7</option>
														<option value="8" <?=$val['breakfast']==8?'selected':''?> >8</option>
														<option value="9" <?=$val['breakfast']==9?'selected':''?> >9</option>
														<option value="10" <?=$val['breakfast']==10?'selected':''?> >10</option>
													</select> 份
												<?}
												?>
                                            </td>
                                            <td onclick="selectPrice('<?=$val['id']?>','<?=$val['parentTypeId']?>','','',0)" style="color: #FF7575;cursor: pointer;" class="onmous"><div><input type="text" name="set_thprice" value="<?=empty($val['sellPrice'])?$v['price']:$val['sellPrice']?>" disabled="" /> ￥</div><span>点击查看价格记录</span></td>
                                            <td><input type="text" name="staTime[<?=$val['id']?>]" value="<?=!empty($val['priceDate'])&&$val['priceDate']>=strtotime(date('Y-m-d'))?date('Y-m-d',$val['priceDate']):date('Y-m-d',time())?>" placeholder="开始时间" readonly="" class="datepickerinput from yes" /></td>
                                            <td><input type="text" name="endTime[<?=$val['id']?>]" value="<?=!empty($val['priceEndDate'])&&$val['priceEndDate']>=strtotime(date('Y-m-d',time()))?date('Y-m-d',$val['priceEndDate']):''?>" placeholder="结束时间" readonly="" class="datepickerinput to yes" /></td>
                                            <td><label style="display: block;width: 100%;height: 100%;"><input type="checkbox" name="check[<?=$val['id']?>]" value="1" style="margin-top: 20px;" /></label></td>
                                            
                                            <?
                                            if($val['zisort']==1){?>
                                                <td rowspan="8">
                                                    <?
                                                    if($channels){
                                                        foreach($channels as $ksy=>$vsy){?>
                                                            <label style="font-weight: 500;margin-right: 5px;"><input type="checkbox" name="channels[]" value="<?=$vsy['osiiId']?>" /> <?=$vsy['title']?></label>
                                                        <?}
                                                    }
                                                    ?>
                                                </td>
                                            <?}
                                            ?>
                                            
                                            <input type="hidden" name="parentTypeId" value="<?=$v['id']?>" />
                                            <?
                                            if($val['zisort']==1){?>
                                                <td rowspan="8" class="for_post"><input type="submit" name="sub" value="确认推送" class="yes show_shadefrist" /><input type="reset" name="reset" value="重置" class="yes" /></td>
                                            <?}
                                            ?>
                                        </tr>
                                    <?}
                                }
                            }
                            ?>
                            <input type="hidden" name="price" value="<?=$v['price']?>" />
                        </tbody>
                    </table>
                    </form>
                    <?}
                }
                ?>
            </div>
        </section>
    </section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
<div id="pop-up-boxes">
    <div id="pop-up-boxes-content">
        <div id="pop-up-boxes-title"><label style="font-weight: 500;margin-left: 10px;"></label><img src="/public/assets/sysadmin/mylzp/img/error.png" /></div>
        <div id="pop-up-boxes-text">
			起始时间：<input type="text" name="sta" class="from2 datepickerinput" value="" readonly="" />
			-
			<input type="text" name="end" class="to2 datepickerinput" value="" readonly="" /><br /><br />
			渠道：<select name="channelsId">
			<option value="0">全部</option>
			<?
			if($channels){
				foreach($channels as $k=>$v){?>
					<option value="<?=$v['osiiId']?>" ><?=$v['title']?></option>
				<?}
			}
			?>
			</select>&nbsp;&nbsp;
			<input type="hidden" name="typeid" value="" /><input type="hidden" name="parentTypeId" value="" />
			<button>搜 索</button><br /><br />
			<table>
				<thead><tr><th>时间</th><th>价格(元)</th><th>渠道</th><th>操作时间</th></tr></thead>
			</table>
			<div>
				<table>
					<tbody><tr><td colspan='4' style='text-align: center;'>无记录</td></tr></tbody>
				</table>
			</div>
        </div>
    </div>
</div>

<script type="text/javascript">
$(function(){
    $(".from").datepicker({
        minDate: 0,
        showMonthAfterYear: true,
        changeMonth: true,
        numberOfMonths: 1,
        showButtonPanel: true,
        showOn: "both",
        onSelect: function( selectedDate ) {
            $(this).parent().next().find('input').datepicker( "option", "minDate", selectedDate );
        }
    });
    $(".to").datepicker({
        minDate: 0,
        showMonthAfterYear: true,
        changeMonth: true,
        numberOfMonths: 1,
        showButtonPanel: true,
        showOn: "both",
    });
	$(".from2").datepicker({
        minDate: 0,
        showMonthAfterYear: true,
        changeMonth: true,
        numberOfMonths: 1,
        showButtonPanel: true,
        showOn: "both",
        onSelect: function( selectedDate ) {
            $(this).next().datepicker( "option", "minDate", selectedDate );
        }
    });
    $(".to2").datepicker({
        minDate: 0,
        showMonthAfterYear: true,
        changeMonth: true,
        numberOfMonths: 1,
        showButtonPanel: true,
        showOn: "both",
    });
    $('.ui-datepicker-trigger').remove();
});
$('table.tables_thall tbody tr.types_top').click(function(){
    var key=$(this).attr('lang');
    var lang=$(this).children('td').children('span').attr('lang');
    if(lang==0){
        $('table.types_table_'+key+' tbody tr.types_zi').css({"display":'none'});
        $(this).children('td').children('span').html('展开∨');
        $(this).children('td').children('span').attr('lang',1);
    }else{
        $('table.types_table_'+key+' tbody tr.types_zi').css({"display":'table-row'});
        $(this).children('td').children('span').html('收起∧');
        $(this).children('td').children('span').attr('lang',0);
    }
});
$('.setPrice').change(function(){
    var zhekouId=$(this).val();
    var zhekou=10-(zhekouId*0.5-0.5);
    var price=$(this).attr('lang');
    var thprice=Math.ceil(zhekou/10*price);
    $(this).parent().next().find('input').val(thprice);
});
$('#formorder .onmous').hover(function(){
	$(this).find('div').hide();
	$(this).find('span').show();
	$(this).css({'background-color':'#999999'});
},function(){
	$(this).find('div').show();
	$(this).find('span').hide();
	$(this).css({'background-color':'#fff'});
});

$('#pop-up-boxes-title img').click(function(){
    $('#pop-up-boxes').hide();
});

$('#pop-up-boxes-text button').click(function(){
	var typeid=$('#pop-up-boxes-text input[name="typeid"]').val();
	var parentTypeId=$('#pop-up-boxes-text input[name="parentTypeId"]').val();
	var sta=$('#pop-up-boxes-text input[name="sta"]').val();
	var end=$('#pop-up-boxes-text input[name="end"]').val();
	var channelsId=$('#pop-up-boxes-text select[name="channelsId"]').val();
	selectPrice(typeid,parentTypeId,sta,end,channelsId);
});

function selectPrice(typeid,parentTypeId,sta,end,channelsId){
	$.ajax({
		type:'POST',
		url:'<?=$this->url("hotel/selectPrice")?>',
		data:'typeid='+typeid+'&parentTypeId='+parentTypeId+'&sta='+sta+'&end='+end+'&channelsId='+channelsId,
		dataType:'json',
		success:function(r){
			if(r.state==1){
				$('#pop-up-boxes-title label').html(r.typeName);
				$('#pop-up-boxes-text input[name="sta"]').val(r.sta);
				$('#pop-up-boxes-text input[name="end"]').val(r.end);
				$('#pop-up-boxes-text input[name="typeid"]').val(r.typeid);
				$('#pop-up-boxes-text input[name="parentTypeId"]').val(r.parentTypeId);
				$('#pop-up-boxes-text select[name="channelsId"]').find("option[value="+r.channelsId+"]").attr("selected",true);
				$('#pop-up-boxes-text table tbody').html(r.html);
				$('#pop-up-boxes').show();
				$('#pop-up-boxes-text table tbody tr').hover(function(){
					$(this).css({'background-color':'#D9D9D9c'});
				},function(){
					$(this).css({'background-color':'#fff'});
				});
			}else{
				pub_alert_error(r.html,2000);
			}
		},
		error:function(){
			pub_alert_error("ajax出现错误",2000);
		}
	});
}

</script>